package com.linb.pan.server.modules.share.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum ShareDayTypeEnum {

    PERMANENT_VALIDITY(0, 0, "永久有效"),

    SEVEN_DAYS_VALIDITY(1, 7, "七天有效"),

    THIRTY_DAYS_VALIDITY(2, 30, "三十天有效");

    private Integer code;

    private Integer days;

    private String desc;

    /**
     * 根据code获取天数
     */
    public static Integer getShareDayByCode(Integer code) {
        if (Objects.isNull(code)) {
            return -1;
        }
        for (ShareDayTypeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.getDays();
            }
        }
        return -1;
    }

}
